package com.richie696.config;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.HiddenHttpMethodFilter;

import javax.servlet.ServletContext;

public class WebApplicationStartup implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) {
        addFilters(servletContext);
        addListeners(servletContext);
    }

    private void addFilters(ServletContext servletContext) {
        servletContext.addFilter("encoding", new CharacterEncodingFilter("UTF-8", true, true));
        servletContext.addFilter("hiddenHttpMethodFilter", new HiddenHttpMethodFilter());
    }

    private void addListeners(ServletContext servletContext) {
        // do sth...
    }
}
